package leafedbox.commands
{
	import flash.events.EventDispatcher;

	/**
	 * This class represents an action.  Commands objects are used to 
	 * encapsulate actions into an object so they are reusable and
	 * can be chained.
	 */
	public class Command extends EventDispatcher
	{
		//--------------------------------------------------------------------------
		// Static constants
		//--------------------------------------------------------------------------
	
		/**
		 * A status indicating success.
		 */
		public static const STATUS_OK : String = "OK";

		/**
		 * A status indicating failure.
		 */
		public static const STATUS_FAIL : String = "FAIL";

		/**
		 * A status indicating that an error has occurred.
		 */
		public static const STATUS_ERROR : String = "ERROR";



		//--------------------------------------------------------------------------
		// Constructor
		//--------------------------------------------------------------------------
	
		/**
		 * Constructor.
		 */
		public function Command():void
		{
		}
	
	
		//--------------------------------------------------------------------------
		// Properties
		//--------------------------------------------------------------------------
	
	    //----------------------------------
	    // Status
	    //----------------------------------

		/**
		 * @private
		 */
		protected var _status : String;

		/**
		 * The status as a result of the command being executed. This field
		 * can be set to <code>Command.STATUS_OK</code> to indicate a success,
		 * <code>Command.STATUS_FAIL</code> to indicate that the command has
		 * failed, or <code>Command.STATUS_ERROR</code> which indicates that
		 * an unexpected error has occurred.
		 */
		public function get status():String
		{
			return _status;
		}


	    //----------------------------------
	    // Status code
	    //----------------------------------

		/**
		 * @private
		 */
		protected var _statusCode : String = "";

		/**
		 * The status code as a result of the command being executed. This field
		 * is not typically used in the case of a successful execution but is
		 * used when a command fails.  The implementation of this property is
		 * left to the subclasses of the <code>Command</code> class.
		 */
		public function get statusCode():String
		{
			return _statusCode;
		}


	    //----------------------------------
	    // Status text
	    //----------------------------------

		/**
		 * @private
		 */
		protected var _statusMessage : String = "";

		/**
		 * A human-readable description of the status as a result of the command
		 * being executed.  Whereas the status code is machine readable, this
		 * property is used to display a message that an end user would be able
		 * to understand.
		 */
		public function get statusMessage():String
		{
			return _statusMessage;
		}



		//--------------------------------------------------------------------------
		// Methods
		//--------------------------------------------------------------------------

		/**
		 * Executes the command.  The implementation of this method is left to the
		 * <code>Command</code> subclasses.
		 */
		public function execute():void
		{
		}

	}

}